package com.example.eeuse.util;

import cn.hutool.core.codec.Base64;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSON;
import com.example.eeuse.model.FareResult;

import java.nio.charset.Charset;
import java.util.HashMap;
import java.util.IdentityHashMap;
import java.util.Map;

public class FareUtil {

    public static HttpRequest createPost()
    {
        String url="https://lfe.csair.com/new_lfe/b2cfqNew_xml.do";
        HttpRequest httpRequest=HttpUtil.createPost(url);
        httpRequest.header("Ssotoken" ,"c978d8a16809f4f19c5187ea9a16444e");
        httpRequest.header("Referer", "https://lfe.csair.com/lfe/pages/B2CFQ/B2CFQSearch_new.html?ip=https://igroup-dom-czfc.csair.com&port=8443");
        httpRequest.header("Content-Type","application/json;charset=UTF-8");
        httpRequest.header("Username" ,"_SSO_T_20080");
        return httpRequest;
    }

    public static Map<String, FareResult.FareXx> fareXxMap(FareResult fareResult)
    {
        Map<String, FareResult.FareXx> fareXxMap=new HashMap<>();
        Map<String, FareResult.FareXx> repeatMap=new IdentityHashMap<>();
        fareResult.getFareXxList().forEach(v->{
            FareResult.FareXx temp=fareXxMap.get(v.parseId());
            if(temp==null)
            {
                fareXxMap.put(v.parseId(),v);
            }
            else {
                repeatMap.put(v.parseId(),v);
                System.out.println(JSON.toJSONString(v));
                System.out.println(JSON.toJSONString(temp));
                System.out.println("----------------------");
            }
        });
        return fareXxMap;
    }
}
